package com.qf.business.user.application;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@Configuration
public class XxlJobConfiguration {

    @Autowired
    private XxlJobProperties xxlJobProperties;

    /**
     * 配置执行器的Bean对象
     * @return
     */
    @Bean
    public XxlJobSpringExecutor getXxlJobExecutor(){
        System.out.println("获取配置信息：" + xxlJobProperties);
        XxlJobSpringExecutor executor = new XxlJobSpringExecutor();
        executor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
        executor.setAppname(xxlJobProperties.getAppname());
        executor.setIp(xxlJobProperties.getIp());
        executor.setPort(xxlJobProperties.getPort());
        executor.setAccessToken(xxlJobProperties.getAccessToken());
        executor.setLogPath(xxlJobProperties.getLogPath());
        executor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays());
        return  executor;
    }
}
